import { useState } from 'react'
export function loadable(obj) {
  let { loader, loading: Loading } = obj;
  let Com;
  Loading = Loading || (() => <h2>加载中</h2>)
  return function (props) {
    let [flag, setFlag] = useState(false)
    loader().then(data => {
      // console.log(data)
      Com = data.default
      setFlag(true)
    })
    return <>
      {
        flag ? <Com {...props} /> : <Loading />
      }

    </>
  }
}